home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / HackAddict™ Magazine / HackAddict 04 / HackAddict 4 / HackAddict 4.rsrc / TEXT_132.txt < prev    next >
Text File  |  1997-07-21  |  9KB  |  169 lines

  1.    Assembly Reference Guide
  2.  
  3.  
  4.  
  5.                                                                       
  6.                              ---===Reference Guide===---                                             
  7.                                      ---===To Assembly Language===---                   
  8.                                             by: ProZaq                               
  9.  
  10.                      
  11.  
  12.  
  13.                                      --==< Intro >==--
  14.  
  15. Wanna be a hacker? Wanna crack? Gotta know assembly! ‚ÄòCause it‚Äôs assembly that makes the world go round! Yes it‚Äôs ugly...Yes it makes you wanna puke...But if you know this you can sit your butt down to any machine and have your way on it! This file WILL NOT deal with how to write assembly code. It‚Äôs a brief explanation of common addressing modes and instructions. It‚Äôs intended to help you to figure out what‚Äôs going on in the code, if you‚Äôre for example stuck on the following command: ‚Äúmove.l  (A7)+,4(A7,D0.l)‚Äù. You will be able to look up exactly what the hell this line executes. I know from personal experience that the toughest part in cracking a program is to follow the code through, and understanding what‚Äôs going on. So that‚Äôs what this file will help you with! Therefore, this file is NOT a TUTORIAL but more of a quick and efficient REFERENCE GUIDE for those who still haven‚Äôt fully gotten the hang of all the different assembly addressing modes and instructions.
  16.  
  17.  
  18.                          --==< Addressing Modes >==--
  19.  
  20. - Data register direct addressing:
  21.            add.b            D0,D1           : adds the value in D0 to D1
  22.  
  23. - Address register direct addressing:
  24.            add.l             D0,A1            : adds value D0 to A1
  25.  
  26. - Address register indirect addressing:
  27.            move.l           (A1),D7          : moves contents of address to data register 
  28.   e.g. if A1 contained $1111, and the address $1111 contains 00001234 then after the operation 00001234 would be loaded in data register 7 (D7).
  29.            move.l              D7,(A1)           : moves number value of D7 into the location pointed to by A1.
  30.  
  31. - Address register indirect with post increment:
  32.            move.l           D7,(A1)+             : moves the long in D7 to memory location in A1 then adds 4 to A1 (because the data item was a long). With other words after the move, it increments the address register by the size of the data
  33.               move.l              (A0)+,(A1)+    : moves four bites from memory location in A0 to memory location in A1 then adds four to A0 and A1
  34.  
  35. - Address register indirect addressing with pre decrement:
  36.            move.b           D0, -(A1)           : decrement A1 by one (because it‚Äôs a byte) then move word in D0 to the address held in A1
  37. (When bytes are moved onto the STACK then the stack pointer changes by 2 because words and longs have to be moved to even addresses)
  38.  
  39. - Address register indirect addressing with displacement:
  40.            move.w              D0,4(A1)           : move word in D0 to the memory location in A1+4.
  41.   e.g. if D0 consists of 01 and A1 contains $1000 then 01 will be moved to address $1004
  42.               move.l               -2(A1),D0              : moves long at A1-2 to D0
  43. (offset has to be a 16 bit word- max value=32768, min value -32767)
  44.  
  45. - Address register indirect addressing with index:
  46.               move.w              69(A1,D0.l),D1          :     moves data word from address A1+D0+69 to D1.
  47. (displacement must fit in a byte, >-127, <128)
  48.  
  49. - Absolute short addressing:
  50.            move.w              69,D0           : moves word at ADDRESS 69 to D0
  51.  
  52. - Immediate mode addressing:
  53.            move.w              #69,D0           : move NUMBER 69 into D0
  54.  
  55. - Absolute long addressing:
  56.            move.w              D0,$69000              : moves word from D0 to address $69000
  57.  
  58. - Program counter addressing with displacement:
  59.            move.w              12(pc),D0           : move word 12 bytes from current location to D0
  60.  
  61. - Program counter addressing with index:
  62.            move.l               69(pc,D0.l),D1              : move data from 69+ current location + D0.l into D1
  63. (displacement must fit into a byte)
  64.  
  65. - Status register addressing:
  66.               move.w           #69,sr           : move number 69 into status register
  67. (to use status register a WORD needs to be moved)
  68.            move.b           #0,ccr                   : move 0 to condition code register
  69.  
  70.  
  71.                             --==< Instructions >==--
  72.  
  73. Arithmetic Instructions:
  74.  - ADD - Adds two operands. One operand must be a data register. 
  75.  - ADDA - Adds an operand to an address register. 
  76.  - ADDI - Adds a real number to an operand.  
  77.  - ADDQ - Adds a number between zero and eight to an operand. 
  78.  - ADDX - Allows adding of numbers of any length. 
  79.  - SUB - Subtracts source operand from destination operand.
  80.  - SUBA - Subtracts the source operand from an address register. 
  81.  - SUBI - Subtracts a real number from the destination operand. 
  82.  - SUBQ - Subtracts a number between zero and eight from a destination operand.  
  83.  - SUBX - Allows subtraction of numbers of any length- CLR - Clears an operand. 
  84.  - MULS - Multiplies destination operand by source operand using signed arithmetic. 
  85.  - MULU - Multiplies destination operand by source operand using unsigned arithmetic
  86.  - DIVS - Divides destination operand by source operand using signed arithmetic.  
  87.  - DIVU - Divides destination operand by source operand using unsigned arithmetic. 
  88.  - NEG - Negates a number.
  89.  - CMP - Compares two operands and sets condition code flags.  
  90.  - CMPA - Compares an operand to an address register then sets the condition code flags. 
  91.  - CMPI - Compares a real number to an operand then sets the condition flags. 
  92.  - CMPM - Compares contents of two memory locations using post increment addressing mode. 
  93.  - TAS - Test a byte and sets the high order bit. 
  94.  - TST - Tests an operand - compares it to zero.
  95.  - EXT - Sign extend a byte or word to word or long respectively.
  96.  
  97. Program Control Instructions:  
  98.  - Bcc - Branch if a condition (cc) is met.  
  99.   Different conditions (cc) for Branch:
  100.                BCC - branch if the carry bit is clear. (a zero)
  101.                BCS - branch if the carry bit is set. (a one) 
  102.                BEQ - branch if equal. 
  103.                BGE - Branch if greater than or equal. 
  104.                BGT - Branch if greater than. 
  105.                BHI - Branch if higher than. Used on unsigned numbers. 
  106.                BLE - Branch if less than or equal. 
  107.                BLS - Branch if lower than or the same. Used on unsigned numbers. 
  108.                BLT - Branch if less than. 
  109.                BMI - Branch if minus. 
  110.                BNE - Branch if not equal. 
  111.                BPL - Branch if plus. 
  112.                BVC - Branch if the V bit is clear. (no overflow)
  113.                BVS - Branch if the V bit is set. (overflow) 
  114.                BRA - Always branch. 
  115.  - DBcc - Decrement then branch if condition is met. 
  116.  - Scc - Set if condition is met.  
  117.  - BSR - Branch to subroutine.  
  118.  - JSR - Jump to subroutine.  
  119.  - RTS - Return from subroutine.  
  120.  - JMP - Jump to an absolute memory location. 
  121.  - RTR - Restores the program counter and condition codes from the stack.  
  122.  
  123. Logical Operation Instructions:
  124.  - AND - Does AND operation with the operands.  
  125.  - ANDI - Does AND operation with a real number and an operand.  
  126.  - OR - Does OR operation with the operands.
  127.  - ORI - Does OR with a real number and an operand.  
  128.  - EOR - Does Exclusive OR with two operands. 
  129.  - EORI - Does Exclusive OR with operand and a real number.
  130.  - NOT - Inverts an operand.    
  131.  
  132. Data Movement Instructions: 
  133.  - EXG - Exchange contents of two registers. 
  134.  - LEA - Load Effective Address. Calculate a memory address and store it in an address register.  
  135.  - LINK - Allocates a stack frame.  
  136.  - MOVE - Move source operand into destination operand. 
  137.  - MOVEM - Transfers multiple register to and from memory. 
  138.  - MOVEP - Transfers data to and from an eight bit peripheral. 
  139.  - MOVEQ - Loads a data register with a number in the range of +- 128. 
  140.  - PEA - Same as LEA, but pushes the address onto the stack. 
  141.  - SWAP - Swaps the words of a data register. The high word becomes the low and the low the high. 
  142.  - UNLK - Unallocates a stack frame.    
  143.  
  144. Shifting and Rotating Instructions:
  145.  - ASL and ASR - Arithmetic shift left or right.  
  146.  - LSL and LSR - Logical shift left or right.  
  147.  - ROL and ROR - Rotate left or right. 
  148.  - ROXL and ROXR - Rotate with the carry bit left or right.   
  149.  
  150. Bit Manipulating Instructions :   
  151.  - BTST - tests a single bit.  
  152.  - BSET - set a single bit.  
  153.  - BCLR - clear a single bit.  
  154.  - BCHG - change a single bit.  
  155.  
  156. System Control instructions:
  157.  - MOVE USP - Move an operand to user stack pointer.  
  158.  - RESET - Reset external peripherals.  
  159.  - RTE - Return from an exception. 
  160.  - STOP - Stop processing until an exception occurs.  
  161.  - TCHK - Check an operand against boundaries - used to prevent serious software errors. 
  162.  - TRAP - 16 instructions that provide a method for user program to call a supervisor mode program.
  163.  
  164.  
  165. This file will probably remain the same in the future however there may be a sequel to it describing the basics of assembly language and it‚Äôs use in cracking software.
  166.  
  167. ProZaq
  168.  
  169.